package demon1;
class Shape{
    public void draw(){
        System.out.println("画图型");
    }
}
class Rect extends Shape{
    @Override
    public void draw(){
        System.out.println("画一个矩形");
    }
}
class Cycle extends Shape{
    @Override
    public void draw(){
        System.out.println("画一个圆");
    }
}
class Triangle extends Shape{
    @Override
    public void draw(){
        System.out.println("画一个三角形");
    }
}
public class Test2 {
    public static void drawMap(Shape shape){
        shape.draw();
    }
    public static void drawMaps(){
        Rect rect=new Rect();
        Triangle triangle=new Triangle();
        Cycle cycle=new Cycle();
        Shape[] shapes={cycle,triangle,rect,rect};  //这里就是向上转型，数组的类型是Shape 名称是shapes.
        for(Shape shape:shapes){
            shape.draw();
        }
    }
    public static void main(String[] args) {
//        drawMap(new Cycle());
//        drawMap(new Rect());
//        drawMap(new Triangle());
        drawMaps();

    }
}
